// pages/mine/com/com-face-scan/com-face-scan.js
import api from "../../../../common/api";
import constant from "../../../../common/constant";
import util from "../../../../utils/util";

Component({
  options: {
    styleIsolation: 'apply-shared',
    addGlobalClass: true,
  },
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  lifetimes: {
    // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
    attached: function() {
      getApp().globalData.loginPromise.then((content) => {
        let params = {
          activityCode: 'MEMBERFISSION',
          fromUserId: content.sessionUser.id,
          antreVar: constant.facetoface
        }

        wx.showLoading({ title: "加载中..." });
        api.qrcodeLongToShort(JSON.stringify(params), {}, res => {
          wx.hideLoading()
          let smallCode = res.data.content;
          let QrCode = util.domain + "miniCode/getWXACodeUnlimit?page=" + encodeURI("pages/index/index") + "&scene=" + smallCode + "&miniName=jjrjs"
          
          this.setData({scanUrl: QrCode})
        })
      })
    },
    moved: function() {},
    detached: function() {},
  },

  /**
   * 组件的方法列表
   */
  methods: {
    handleClose() {
      this.triggerEvent('toggle')
    },

    
  }
})
